package com.sea.service;


import com.sea.struct.annotation.InputTypeStruct;
import org.reflections.Reflections;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

@Component
public class SwapManager implements ISwapManager {
    private static Logger logger = LoggerFactory.getLogger(SwapManager.class);

    public static Map<Long, Class<?>> HANDLE_CLASS = new HashMap<>();

    public static Map<Long, Class<?>> INPUT_STRUCT_CLASS = new HashMap<>();

    static {
//		Reflections reflections = new Reflections("com.onestar.hextool.handle");
//		Set<Class<?>> set = reflections.getTypesAnnotatedWith(TypeHandle.class);
//
//		for (Class<?> cls : set) {
//			TypeHandle struct = cls.getAnnotation(TypeHandle.class);
//			System.out.println("HANDLE："+struct.value());
//			HANDLE_CLASS.put(struct.value(), cls);
//		}

		Reflections reflections = new Reflections("com.sea.struct");
		Set<Class<?>> set = reflections.getTypesAnnotatedWith(InputTypeStruct.class);
		for (Class<?> cls : set) {
			InputTypeStruct struct = cls.getAnnotation(InputTypeStruct.class);
			System.out.println("STRUCT："+struct.value());
			INPUT_STRUCT_CLASS.put(struct.value(), cls);
		}
    }




}
